<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
      div{
        color: rebeccapurple;
        font-size: 30px;
      }
    </style>
  </head>
  <body>
    <div>时钟案例:</div>
    <div>
      <span id="HH">00</span>:<span id="mm">00</span>:<span id="ss">00</span>
    </div>

    <script>
      window.onload =  function(){
        setInterval(()=>{
          const dt = new Date()
          const HH = dt.getHours()
          const mm = dt.getMinutes()
          const ss = dt.getSeconds()
          document.getElementById('HH').innerText = HH
          document.getElementById('mm').innerText = mm
          document.getElementById('ss').innerText = ss
        },1000)
      }
    </script>
  </body>
</html>